package ipad.asia.service.seckill;

import com.alibaba.fastjson.JSON;
import ipad.asia.entity.SeckillProduct;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;

@Component
@FeignClient(value = "PROVIDER-SECKILL")
public interface SecKillFeign {


    /**
     * 返回1表示库存不足，2表示不可重复抢购，没人一件，3表示成功！
     * @param productId
     * @param consumerId
     * @return
     */
    @RequestMapping("/secKill/go")
      int secKill(@RequestParam(value = "productId") int productId,
                         @RequestParam(value = "consumerId") int consumerId);




    @GetMapping("/secKill/list")
     List<SeckillProduct> products();


    @RequestMapping("/secKill/productSave")
     void addSecKill(@RequestParam(value = "productId",required = false) Integer productId,
                           @RequestParam(value = "price",required = false)Float price,
                           @RequestParam(value = "number",required = false)Integer number,
                           @RequestParam(value = "start",required = false) String start,
                           @RequestParam(value = "end",required = false) String end);

    @RequestMapping("/secKill/delete")
    void deleteSecKill(@RequestParam(value = "productId",required = false) Integer productId);

    @RequestMapping("/secKill/getById")
     SeckillProduct getById(@RequestParam(value = "productId",required = false) Integer productId);


    @RequestMapping("/secKill/StartById")
     SeckillProduct StartById(@RequestParam(value = "productId",required = false) Integer productId);


    @Transactional
    @RequestMapping("/secKill/deleteNoPay")
     void deleteNoPay(@RequestParam(value = "productId",required = false) Integer productId,
                            @RequestParam(value = "consumerId",required = false)Integer consumerId);

}
